home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / Codeworks 0.94b3 / Codeworks® WWW Demo Doc. / Scripting Manual.doc / Scripting Manual.doc.rsrc / TEXT_157.txt < prev    next >
Encoding:
Text File  |  1995-05-01  |  4.5 KB  |  111 lines

  1. Grammar
  2.  
  3.     This is a grammar of the language presented in an enhanced BNF format:
  4.      sym    ::= sequence-a    ‚Äî a production of sym with two alternatives
  5.             ::= sequence-b
  6.             { sequence  }    ‚Äî an optional sequence
  7.             { sequence  }*    ‚Äî optional sequence zero or more times
  8.             e    ‚Äî the empty sequence
  9.  
  10.     Short semantic descriptions are in italics.  Where ambiguous, the first of several alternatives is favored.
  11.  
  12.  [ This grammer is not totally acurate.  It doesn‚Äôt handle operator precedence. ]
  13.         
  14.  
  15. Language Elements
  16.  
  17. script    ::= block
  18.     ::= { decl }* primExp
  19.         A script is either a block of code, or a primitive.
  20.  
  21. block    ::= { decl }* { expression . }*  { return } { expression } { . }
  22.         a block consists of optional declarations followed by a sequence of expressions, which are executed in turn.  The block may end in a return in which case the script (not just the block) is exited.  The return may have an expression whose value is returned as the value of script.  In absence of a return, the value of a block is the value of the last expression, and a script will return no value.
  23.  
  24. decl    ::= $ formals .
  25.  
  26. formals    ::= formal { , formal }*
  27.     ::= e
  28.  
  29. formal    ::= functor word    named argument
  30.     ::= - word    positional argument
  31.     ::= functor    named argument with same local name
  32.     ::= word    local variable
  33.  
  34. primExp    ::= primitive { word , } message { . }
  35.     ::= primitive { word , } number { . }
  36.         The optional word is the name of the primitive set, and either the message or number is key to which primitive.
  37. expression    ::= expHead { expTail }*
  38.         The base expression is executed, then the tail expressions left to right.  Finally head expressions, right to left.
  39.  
  40. expHead    ::= message value argsSet
  41.     ::= value { message argsSet }
  42.     ::= valSet
  43.         in the first two forms, the message is sent to the value with arguments; in the third form the result is the value
  44.  
  45. expTail    ::= ; message argsSet
  46.     ::= ops argsSet
  47.         the message (or operator) is sent to the value from the right with arguments
  48.  
  49. argsSet    ::= args { := expression }
  50.         If there is an assignment then the whole message that these args are for is an assignment message; the value of the expression forms the last positional parameter to the message.
  51.  
  52. args    ::= arg { { , } arg }*
  53.     ::= e
  54.  
  55. arg    ::= keyword value    named argument with value
  56.     ::= keyword    ‚Äòflag‚Äô argument, implied value of true
  57.     ::= value    positional argument
  58.  
  59. valSet    ::= word := expression    (1)
  60.     ::= word ?= expression    (3)
  61.     ::= value := expression    (2)
  62.         The value of the expression to the right of the assignment symbol (the := or ?=) is assigned to the variable or value.  The value of this assignment is the value of the expression.
  63.         1) word may be a local or a property of self
  64.         2) conditional assignment is made to either an argument or local (assignment is only made if the argument wasn‚Äôt passed in, or if the local hasn‚Äôt been assigned to yet
  65.         3) the property named by the value is assigned to (for example foo.x or foo @ 3).
  66.  
  67. value    ::= primary { member }* { ! }
  68.     ::= primary { member }* ops
  69.     ::= operator value ops
  70.         the members are evaluated left to right, each names a property that is fetched from the value to the left;  If there is an exclamation, then the value is checked for undefined and a run-time error is generated if it is
  71.  
  72. opsSet    ::= ops := expression
  73.  
  74. ops    ::= operator value { ops }
  75.  
  76. primary    ::= word { ? }    (1)
  77.     ::= self
  78.     ::= number
  79.     ::= string
  80.     ::= symbol
  81.     ::= special
  82.     ::= ( expression )    value is the value of the expression
  83.     ::= [ block ]    value is a block object
  84.         1) the word may be either a local, an argument, a global, or a property of self whose value is fetched.  In the case of locals or arguments, the optional question mark results in a value of true or false, depending of if the value is defined or not.
  85.  
  86.  
  87. Lexical Elements
  88.  
  89. .  ,  ;  (  )  [  ]  ?  !  :=  ?=  $  -
  90.  the literal punctuation marks and symbols
  91.  
  92. return    the bold literal:    return
  93.  
  94. self    any of the literals:   self   this   super
  95.  
  96. number    a decimal number with optional fractional part and exponent, or a binary, octal, or hexadecimal number; may have a leading minus sign
  97.  
  98. string    a string of characters between double quotes; must appear on one line; can contain quoted special characters using the backslash notation
  99.  
  100. symbol    a dollar sign followed directly by any legal word or operator
  101.  
  102. special    any of the literals:   true   false   nil   ???
  103.  
  104. word    any non-bold sequence of alphabetic, numeric, or dash characters that begins with an alphabetic
  105.  
  106. functor    a bold version of word
  107.  
  108. operator    any sequence of the operator characters:   ! # $ % & * + - / : < = > ? @ \ ^ | ~ except the sequences:   $  :=  ?=  ?  ! 
  109.  
  110. member    a word preceded by a period
  111.